package com.songwo.core.primary.entity.system;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;

/**
 * @author zhongzheng
 * @description 系统角色实体类
 * @date 2018/5/29 9:02
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class SysRole implements Serializable{

    private static final long serialVersionUID = 5868849978023444480L;

    @Id
    @GeneratedValue
    private Long id;

    /**
     * 角色名称
     */
    @Column(nullable = false)
    private String roleName;

    /**
     * 创建时间
     */
    @Column(nullable = false)
    private Date createTime;

    /**
     * 创建人
     */
    @Column(nullable = false)
    private Long createUser;

    /**
     * 更新时间
     */
    @Column
    private Date updateTime;

    /**
     * 更新人
     */
    @Column
    private Long updateUser;

    /**
     * 权限列表
     */
    @JsonIgnore
    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinTable(name = "rel_sysrole_syspermission", joinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "permission_id", referencedColumnName = "id")})
    private Set<SysPermission> permissionSet;
}
